package com.ytjj.qmyx.admin.eunm;

import com.ytjj.qmyx.admin.model.response.ActivityTypeResponse;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum ActivityEnums {

    CASH_SCORE("CASH_SCORE", "兑换中心"),
    GET_SCORE("GET_SCORE", "全额返"),
    CASH_COUPON("CASH_COUPON", "红包抵扣"),
    SECKILL("SECKILL", "超级秒杀"),
    OLD_FOR_NEW("OLD_FOR_NEW", "品牌补贴"),
    RECHARGE_COUPON("RECHARGE_COUPON", "购物返话费"),
    RETURN_COUPON("RETURN_COUPON", "红包返现"),
    PAY_AFTER_USE("PAY_AFTER_USE", "先用后付"),
    ZERO_EVALUATION("ZERO_EVALUATION","0元测评"),
    GROUP_WORK("GROUP_WORK", "拼团活动"),
    CHINA_GOLD("CHINA_GOLD", "中国黄金"),
    SHOPPING_CARD("SHOPPING_CARD", "购物卡"),
    GUESS_LIKE("GUESS_LIKE", "猜你喜欢"),
    LIVING_CENTER("LIVING_CENTER","9.9生活馆"),
    ASSESSMENT_PAID("ASSESSMENT_PAID","收费测评"),
    MEMBER_SALE("MEMBER_SALE", "会员特卖"),
    MEMBER_SUBSIDY("MEMBER_SUBSIDY", "会员享补贴"),
    WALLET_DEDUCT("WALLET_DEDUCT", "钱包抵扣"),
    FROM_APP("FROM_APP","APP移除"),
    SHOPPING_CARNIVAL("SHOPPING_CARNIVAL","购物狂欢节"),
    U_TRY("U_TRY", "U先试用"),
    RETROACTIVE_CARD("RETROACTIVE_CARD", "补签卡"),
    PENNY_CONVERSION("PENNY_CONVERSION", "一分兑"),
    WINE_WELFARE("WINE_WELFARE", "名酒福利专场"),
    HOT_SALE("HOT_SALE", "爆款特卖"),
    ;

    /**
     * 活动类型
     */
    private String activityCode;

    /**
     * 活动描述
     */
    private String activityType;

    ActivityEnums(String activityCode, String activityType) {
        this.activityCode = activityCode;
        this.activityType = activityType;
    }

    /**
     * 获取活动类型
     *
     * @param activityCode
     * @return
     */
    public static String getActivityType(String activityCode) {
        ActivityEnums[] values = ActivityEnums.values();
        for (ActivityEnums value : values) {
            if(value.activityCode.equals(activityCode)) {
                return value.getActivityType();
            }
        }
        return null;
    }

    /**
     * 获取枚举值常量列表
     *
     * @return
     */
    public static Map<String, String> getEumValueList() {
        Map<String,String> map = new HashMap<>();
        for (ActivityEnums value : ActivityEnums.values()) {
            map.put(value.getActivityCode(),value.getActivityType());
        }
        return map;
    }

    /**
     * 根据枚举code获取名称
     * @param code
     * @return
     */
    public static String getName(String code){
        ActivityTypeNameCode[] list = ActivityTypeNameCode.values();
        for (ActivityTypeNameCode item : list) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }
    public static List<ActivityTypeResponse> getTypeList() {
        List<ActivityTypeResponse> list = new ArrayList<>();
        ActivityTypeNameCode[] typeList = ActivityTypeNameCode.values();
        for (ActivityTypeNameCode type : typeList) {
            ActivityTypeResponse atp = new ActivityTypeResponse();
            atp.setCode(type.getCode());
            atp.setName(getName(type.getCode()));
            list.add(atp);
        }
        return list;
    }
}
